<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>

<head>
<title>快递单流量导入模版设置</title>
<script type="text/javascript">
	var map={};
	function setParam() {
		var keys = $("#keys").val();
		var values = $("#values").val();
		var keyvalue=$("#values option:selected").text();
		map[values]=keyvalue;
		if (keys == null || values == null) {
			return;
		}
		$("#keys option[value='" + keys + "']").remove();
		$("#values option[value='" + values + "']").remove();
		$("#content").prepend("<option value='" + values + "'>" + keys + "</option>");

	}
	
	function setParamBack() {
		var keys = $("#content").val();
		var values = $("#content option:selected").text();
		if (keys == null || values == null) {
			return;
		}
		$("#content option[value='" + keys + "']").remove();
		$("#keys").prepend("<option value='" + values + "'>" + values + "</option>");
		$("#values").prepend("<option value='" + keys + "'>" + map[keys] + "</option>");
		delete map[keys];
	}
	
	function getParam() {
		var tempString = "";
		$("#content option").each(function() {
			var text = $(this).text();
			var value = $(this).val();

			if ("" == tempString) {
				tempString = text + ":" + value;
			} else {
				tempString += "," + text + ":" + value;
			}
		});
		return tempString;
	}

	function ajaxLeadCusromerParam(customerCode, type, params) {
		$.ajax({
			type : 'post',
			url : '${ctx}/v2/expressBillManage/ajaxLeadExpressBillMould',
			data : 'customerCode=' + customerCode + '&params=' + params + '&type=' + type,
			dataType : 'json',
			success : function(data) {
				alert(data.content);
			},
			error : function() {
				alert("获取信息错误！");
			}
		});
	}

	function ajaxParam() {
		var params = getParam();
		//ajaxLeadCusromerParam('${customerCode}', '${type}', params);
		ajaxLeadCusromerParam('STO', 'setExpressBillMould', params);
	}
</script>
</head>

<body>
	<div class="row">
		<div class="col-md-12" style="height: 600px;">
			<div class="col-sm-3">
				<select id="keys" name="keys" multiple="multiple"
					class="oldSelectStyle" style="height: 600px; width: 180px;">
					<c:forEach items="${keys}" var="key">
						<option value="${key}">${key}</option>
					</c:forEach>
				</select>
			</div>
			<div class="col-sm-3">
				<select id="values" name="values" multiple="multiple"
					class="oldSelectStyle" style="height: 600px; width: 180px;">

					<option value="customerId">商家ID</option>
					<option value="customerName">商家名称</option>
					<option value="netWork">寄件网点</option>
					<option value="expressNo">运单编号</option>
					<option value="orderNo">订单编号</option>
					<option value=fromProvince>发件省</option>
					<option value="fromCity">发件市</option>
					<option value="fromDistrict">发件区</option>
					<option value="fromStreet">发件街道</option>
					<option value="fromAddress">发件详细地址</option>
					<option value="fromName">发件人姓名</option>
					<option value="fromTele">发件人电话</option>
					<option value="toProvince">收件省</option>
					<option value="toCity">收件市</option>
					<option value="toDistrict">收件区</option>
					<option value="toStreet">收件街道</option>
					<option value="toAddress">收件详细地址</option>
					<option value="toName">收件人姓名</option>
					<option value="toTele">收件人电话</option>
					<option value="orderTime">下单时间</option>
					<option value="weight">重量</option>
					<option value="volume">体积</option>
					<option value="headLine">大字(大头笔)</option>
				</select>
			</div>
			<div class="col-sm-6">
				<table style="height: 600px;">
					<tr>
						<td><input type="button" class="btn btn-primary" value=">>>>" onclick="setParam();" /><br><br>
							<input type="button" class="btn btn-primary" value="<<<<" onclick="setParamBack();" /></td>
						<td style="width: 60px;"></td>
						<td><select id="content" name="content" multiple="multiple"
							style="height: 600px; width: 180px;" class="oldSelectStyle"></select>
						</td>
					</tr>
				</table>
			</div>
		</div>
	</div>
	<div class="row">
		<div class="col-sm-6">
			<input id="submit_btn" class="btn btn-primary" type="button"
				value="设置" onclick="ajaxParam()" /> 
			<input id="cancel_btn"
				class="btn" type="button" value="返回" onclick="window.location.href ='${ctx}/v2/expressBillManage/init'" />
		</div>
	</div>
</body>

</html>